package it.test.socket.domain;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @Copyright 纳新智能科技有限公司
 * @Author Liky
 * @Date 2023/6/7
 */
public class WorkThread implements Runnable{

    static BlockingQueue<Runnable> tasks = new ArrayBlockingQueue<>(10);

    @Override
    public void run() {
        while (true){
            try {
                Runnable task = tasks.poll(2, TimeUnit.SECONDS);
                if(null == task){
                    break;
                }
                task.run();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
